package com.gw.vip.server.service.dao_service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gw.vip.common.exception.ServiceException;
import com.gw.vip.server.dao.TransLockMapper;
import com.gw.vip.server.po.TransLock;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDate;
import java.util.List;

/**
 * @author GW
 * @description
 * @since 2022-05-07
 */
@Service
@Slf4j
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class TransLockService extends ServiceImpl<TransLockMapper, TransLock> {

    private final TransLockMapper mapper;

    public List<TransLock> listByTransId(String transId) {
        return this.mapper.listByTransId(transId);
    }

    public void setClearDateById(LocalDate clearDate, String id) {
        this.mapper.setClearDateById(clearDate, id);
    }

    public void deleteById(String id) {
        if (StringUtils.isBlank(id)){
            log.error("id为空！");
            throw new ServiceException("id为空！");
        }
        this.mapper.deleteById(id);
    }
}
